package Graficas;


import java.awt.*;

import javax.swing.*;

/*
 * El codigo para el splash lo obtuvimos de una fuente de internet, y lo modificamos segun nuestras necesidades 
 * 
 * Fuente del Codigo:
 * http://www.java-tips.org/java-se-tips/javax.swing/how-to-implement-a-splash-screen-for-an-applic-2.html
 */

public class SplashScreen extends JWindow {

	private int duration;

	public SplashScreen(int d) {
		duration = d;

	}

	public void showSplash() {

		JPanel content = (JPanel) getContentPane();
		content.setBackground(Color.black);
		int width = 500;
		int height = 500;
		Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
		int x = (screen.width - width) / 2;
		int y = (screen.height - height) / 2;
		setBounds(x, y, width, height);
		
		JLabel label = new JLabel(new ImageIcon(getClass().getResource("/FilesJuego/images/GokuBlack.jpg")));
		JLabel copyrt = new JLabel("by : Matias Varela & Mariano Rodecker     Version 2.0", JLabel.RIGHT);
		copyrt.setFont(new Font("Sans-Serif", Font.BOLD, 12));
		content.add(label, BorderLayout.CENTER);
		content.add(copyrt, BorderLayout.SOUTH);
		Color oraRed = new Color(54, 56, 56);
		content.setBorder(BorderFactory.createLineBorder(oraRed, 10));
		JProgressBar barra = new JProgressBar(0, duration);
		barra.setValue(0);
		barra.setStringPainted(true);
		barra.setBackground(Color.BLACK);
		content.add(barra, BorderLayout.NORTH);
		int progreso = 0;
		while (progreso <= duration) {
			barra.setValue(progreso);
			progreso++;
			try {
				Thread.sleep(1);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			setVisible(true);
		}
		setVisible(true);
		setVisible(false);

	}

	public void showSplash2() {
		showSplash();
	}
}
